/*
 * @Author: sjr
 * @Date: 2021-02-01 07:11:39
 * @LastEditTime: 2021-02-01 07:33:52
 * @LastEditors: sjr
 * @Description: 描述
 * @FilePath: \leetcode\26.删除排序数组中的重复项.js
 */
/*
 * @lc app=leetcode.cn id=26 lang=javascript
 *
 * [26] 删除排序数组中的重复项
 */

// @lc code=start
/**
 * @param {number[]} nums
 * @return {number}
 */
var removeDuplicates = function(nums) {
  let head = 0
  let index = 1
  for(let i = 0;i<nums.length; i++) {
    if(nums[head] !== nums[i]){ // 相等
      nums[index] = nums[i]
      head=i
      index++
    }
  }
  return index
};
// @lc code=end

